}
if (!nourl && wpt->hasLink()) {
- int len = 7+strlen(wpt->url);
+ int len = 7 + wpt->url.length();
char* extra = (char*)xmalloc(len);
- sprintf(extra, "{URL=%s}", wpt->url);
+ sprintf(extra, "{URL=%s}", wpt->url.toUtf8().data());
rec->name = xstrappend(rec->name, extra);
xfree(extra);
- rec->url = xstrdup(wpt->url);
+ rec->url = xstrdup(wpt->url.toUtf8().data());
}
if (wpt->notes) {
}
const char *
-cet_convert_string(QString str) {
- return cet_convert_string(str.toUtf8().data());
+cet_convert_string(const QString& str) {
+ // FIXME: this is really weird. Since cet_convert_string wants to free
+ // its argument (!) we make a duplicate just to satisfy that kind of goofy
+ // requirement.
+ return cet_convert_string(xstrdup(str.toUtf8().data()));
}
/* cet_convert_waypt: internal used within cet_convert_strings process */
/* cet_convert_string: !!! ONLY VALID WITHIN 'cet_convert_strings' process !!! */
char* cet_convert_string(char* str);
-const char* cet_convert_string(QString str);
+const char* cet_convert_string(const QString& str);
/* gpsbabel extensions */
if (wpt->shortname != NULL) {
waypt_add(waypt_dupe(wpt));
+#if 0
if (wpt->url != NULL) {
xfree(wpt->url);
wpt->url = NULL;
}
+#else
+ wpt->url.clear();
+#endif
if (temp_route == NULL) {
temp_route = route_head_alloc();
off = strlen(xcsv_urlbase);
}
if (wpt->hasLink()) {
- snprintf(buff + off, sizeof(buff) - off, fmp->printfc, wpt->url);
+ snprintf(buff + off, sizeof(buff) - off, fmp->printfc, wpt->url.toUtf8().data());
} else {
strcpy(buff, (fmp->val && *fmp->val) ? fmp->val : "\"\"");
}
break;
case XT_URL_LINK_TEXT:
snprintf(buff, sizeof(buff), fmp->printfc,
- (wpt->hasLinkText()) ? wpt->url_link_text : fmp->val);
+ (wpt->hasLinkText()) ? wpt->url_link_text.toUtf8().data() : fmp->val);
break;
case XT_ICON_DESCR:
writebuff(buff, fmp->printfc,
class url_link {
public:
url_link() :
- url_next(NULL),
- url(NULL),
- url_link_text(NULL)
+ url_next(NULL)
{} ;
url_link* url_next;
- char* url;
- char* url_link_text;
+ QString url;
+ QString url_link_text;
};
/*
description(NULL),
notes(NULL),
url_next(NULL),
- url(NULL),
- url_link_text(NULL),
#if NEWTIME
// creation_time(QDateTime::fromTime_t(0)),
#else
* members must match struct url_link...
*/
url_link* url_next;
- bool hasLink() const {return url && *url; }
- bool hasLinkText() const {return url_link_text && *url_link_text; }
- char* url;
- char* url_link_text;
+ bool hasLink() const {return !url.isEmpty(); }
+ bool hasLinkText() const {return !url_link_text.isEmpty(); }
+ QString url;
+ QString url_link_text;
wp_flags wpt_flags;
QString icon_descr;
void waypt_flush_all(void);
unsigned int waypt_count(void);
void set_waypt_count(unsigned int nc);
-void waypt_add_url(waypoint* wpt, char* link, char* url_link_text);
+void waypt_add_url(waypoint* wpt, const QString& link,
+ const QString& url_link_text);
void free_gpx_extras(xml_tag* tag);
void xcsv_setup_internal_style(const char* style_buf);
void xcsv_read_internal_style(const char* style_buf);
res->url = FREAD_CSTR;
if (wpt_class != 0) {
- res->description = res->url;
- res->url = NULL;
+ res->description = xstrdup(res->url.toUtf8().data());
+ res->url.clear();
}
} else { // if (gdb_ver >= GDB_VER_3)
int i, url_ct;
FWRITE(zbuf, 3);
FWRITE(zbuf, 4);
descr = (wpt_class < gt_waypt_class_map_point) ?
- wpt->url : wpt->description;
+ wpt->url.toUtf8().data() : wpt->description;
if ((descr != NULL) && (wpt_class >= gt_waypt_class_map_point) && \
(strcmp(descr, wpt->shortname) == 0)) {
descr = NULL;
cnt++;
}
for (url_next = wpt->url_next; (url_next); url_next = url_next->url_next)
- if (url_next->url) {
+ if (!url_next->url.isEmpty()) {
cnt++;
}
FWRITE_i32(cnt);
FWRITE_CSTR(wpt->url);
}
for (url_next = wpt->url_next; (url_next); url_next = url_next->url_next)
- if (url_next->url) {
- FWRITE_CSTR(url_next->url);
+ if (!url_next->url.isEmpty()) {
+ FWRITE_CSTR(url_next->url.toUtf8().data());
}
}
if ((test != NULL) && (route_flag == 0)) {
if ((str_not_equal(test->notes, refpt->notes)) ||
- (str_not_equal(test->url, refpt->url))) {
+ test->url.compare(refpt->url)) {
test = NULL;
}
}
if (strcmp(wpt->description, wpt->shortname)) {
if (wpt->hasLink()) {
char* d = html_entitize(wpt->description);
- gbfprintf(file_out, "<a href=\"%s\">%s</a>", wpt->url, d);
+ gbfprintf(file_out, "<a href=\"%s\">%s</a>", wpt->url.toUtf8().data(), d);
xfree(d);
} else {
gbfprintf(file_out, "%s", wpt->description);
return r;
}
-static void kml_write_data_element(const char* name, const char* value)
+static void kml_write_data_element(const char* name, const QString& value)
{
writer.writeStartElement("Data");
writer.writeAttribute("name", name);
if (waypointp->hasLink()) {
writer.writeEmptyElement("snippet");
if (waypointp->hasLinkText()) {
- char* odesc = xml_entitize(waypointp->url);
- char* olink = xml_entitize(waypointp->url_link_text);
+ // FIXME(robertlipe): these call to xml_entitize are suspicios with
+ // new XML serializer.
+ char* odesc = xml_entitize(waypointp->url.toUtf8().data());
+ char* olink = xml_entitize(waypointp->url_link_text.toUtf8().data());
writer.writeStartElement("description");
writer.writeCDATA(QString("<a href=\"%1\">%2</a>").arg(odesc, olink));
writer.writeEndElement(); // Close description tag
}
static void
-lmx_write_xml(int tag, const char* data, int indent)
+lmx_write_xml(int tag, const QString& data, int indent)
{
lmx_start_tag(tag, indent);
gbfputc(0x03, ofd); // inline string follows
gbfputcstr(data, ofd);
} else {
- char* tmp_ent = xml_entitize(data);
+ char* tmp_ent = xml_entitize(data.toUtf8().data());
gbfputs(tmp_ent, ofd);
xfree(tmp_ent);
}
wpt->notes = xstrdup(wpt2->notes);
}
if (wpt2->hasLink()) {
- wpt->notes = xstrdup(wpt2->url);
+ wpt->notes = xstrdup(wpt2->url.toUtf8().data());
}
wpt->proximity = wpt2->proximity;
if (wpt->hasLink()) {
str = xstrdup("_FILE_ ");
- str = xstrappend(str, wpt->url);
+ str = xstrappend(str, wpt->url.toUtf8().data());
str = xstrappend(str, "\n");
} else {
str = xstrdup("");
RCR,
MILLISECOND,
DISTANCE,
-} DATA_TYPES;
+} /* DATA_TYPES */;
struct log_type {
int id;
id = atoi(ap[1]);
xasprintf(&wpt_tmp->shortname, "N%05X", id);
- xasprintf(&wpt_tmp->url, "%s%d", NC_URL, id);
+ wpt_tmp->url = QString(NC_URL) + QString::number(id);
} else if (0 == strcmp(ap[0], "name")) {
wpt_tmp->description = xstrdup(ap[1]);
} else if (0 == strcmp(ap[0], "user_name")) {
wpt->altitude,
colour,
icon,
- wpt->hasLink() ? wpt->url : ""
+ wpt->hasLink() ? wpt->url.toUtf8().data() : ""
);
gbfprintf(file_out, "ADR:%c%d %06.3f %c%d %06.3f\n", wpt->latitude < 0 ? 'S' : 'N', abs(latint), 60.0 * (fabs(wpt->latitude) - latint), wpt->longitude < 0 ? 'W' : 'E', abs(lonint), 60.0 * (fabs(wpt->longitude) - lonint));
if (wpt->hasLink()) {
- gbfprintf(file_out, "URL:%s\n", wpt->url);
+ gbfprintf(file_out, "URL:%s\n", wpt->url.toUtf8().data());
}
gbfprintf(file_out, "NOTE:");
if (wpt->notes) {
tmp->notes = xstrdup(wpt->notes);
}
- if (wpt->url) {
- tmp->url = xstrdup(wpt->url);
- }
- if (wpt->url_link_text) {
- tmp->url_link_text = xstrdup(wpt->url_link_text);
- }
+
+ tmp->url = (wpt->url);
+ tmp->url_link_text = wpt->url_link_text;
for (url_link* url_next = wpt->url_next; url_next; url_next = url_next->url_next) {
- waypt_add_url(tmp,
- (url_next->url) ? xstrdup(url_next->url) : NULL,
- (url_next->url_link_text) ? xstrdup(url_next->url_link_text) : NULL);
+ waypt_add_url(tmp, url_next->url, url_next->url_link_text);
}
tmp->icon_descr = wpt->icon_descr;
if (wpt->notes) {
xfree(wpt->notes);
}
- if (wpt->url) {
- xfree(wpt->url);
- }
- if (wpt->url_link_text) {
- xfree(wpt->url_link_text);
- }
if (wpt->url_next) {
url_link *url_next;
for (url_next = wpt->url_next; url_next;) {
url_link *tonuke = url_next;
- if (tonuke->url) {
- xfree(tonuke->url);
- }
- if (tonuke->url_link_text) {
- xfree(tonuke->url_link_text);
- }
url_next = tonuke->url_next;
xfree(tonuke);
}
}
void
-waypt_add_url(waypoint *wpt, char *link, char *url_link_text)
+waypt_add_url(waypoint *wpt, const QString& link, const QString& url_link_text)
{
if ((link == NULL) && (url_link_text == NULL)) {
return;
wpt->url_link_text = url_link_text;
} else {
url_link *tail;
- url_link *new_link = (url_link*) xcalloc(sizeof(url_link), 1);
+ url_link *new_link = new url_link;
new_link->url = link;
new_link->url_link_text = url_link_text;